package com.eascs.web.o2o.web.reward.dao;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Repository;

import com.eascs.app.dao.JdbcSession;
import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.SqlPageQuery;
import com.eascs.web.o2o.web.reward.entity.PersonalInfo;

@Repository
public class BaseDao {

	@Inject
	JdbcSession jdbcSessionBiReward;
	
	public <T> List<T> findAllEntity(Class<T> returnType ){
		return jdbcSessionBiReward.findAllEntitys(returnType);
	}
	
	public <T> List<T> findEntitys(String sql ,Class<T> returnType ,Object... params){
		return jdbcSessionBiReward.findEntitys(sql, returnType ,params);
	}
	
	public <T> PageResult<T> findDataWithPage(SqlPageQuery<T> sqlPageQuery) {
		return jdbcSessionBiReward.findDataWithPage(sqlPageQuery);
	}
	
	public <T> int deleteEntitys(Object entity){
		return jdbcSessionBiReward.deleteEntitysWithAny(entity);
	}
	
	public boolean executeSql(String sql , Object... params){
		return jdbcSessionBiReward.execute(sql, params) >=0?true:false;
	}
	
	public List<Object[]> executeSqlForObjectArray(String sql){
		return jdbcSessionBiReward.findObjectsList(sql);
	}
	
	public boolean saveEntity(Object entity){
		return jdbcSessionBiReward.insert(entity)>0?true:false;
	}
	
	public PersonalInfo findPersonalInfo(String sql){
		return jdbcSessionBiReward.findEntity(sql, PersonalInfo.class);
	}
	
	public  String  getSql(String sql){
		return jdbcSessionBiReward.getSql(sql);
	}
	
	public boolean updateEntity(Object entity) {
		return jdbcSessionBiReward.updateById(entity)>0?true:false;
	}
	
	public String findString(String sql){
		return jdbcSessionBiReward.findString(sql);
	}
}
